//author:kakake
class tsFrontShowController {
    public data = {
        dbConn: TSLobsterAPI.Program.GetDbConn()
    }

    public dao=new tsFrontShowDao();

    getindexdata(){
        var websiteid=TSLobsterAPI.Program.RequestQuery("websiteid", "0");
        var data= this.dao.getindexdata(websiteid);
        return {data:data};
    }

    getindexdata2(){
        var websiteid=TSLobsterAPI.Program.RequestQuery("websiteid", "0");
        var workid=TSLobsterAPI.Program.RequestQuery("workId", "0");

        var data=this.dao.getindexdata2(websiteid,workid);
        return {data:data};
    }

    gettitledata(){
        var websiteid=TSLobsterAPI.Program.RequestQuery("websiteid", "0");
        var workid=TSLobsterAPI.Program.RequestQuery("workId", "0");
        var arrlist=[];
        var list=this.dao.gettitledata(websiteid,workid);
        list.forEach(res=>{
            var item = {};
            item["NID"] = res["nid"];
            item["NodeName"] = res["nodename"];
            arrlist.push(item);
        })
        return {data:arrlist};
    }

    getitemdata(){
        var pageInfo = {
            key: "ID",
            page: parseInt(TSLobsterAPI.Program.RequestQuery("page", "1")),
            perPage:parseInt(TSLobsterAPI.Program.RequestQuery("pagesize", "999")),
            totalRecord: 100,
            totalPage:0
        };
        var id=TSLobsterAPI.Program.RequestQuery("id", "0");

        var list=this.dao.getitemdata(id,pageInfo);
        
        return { data: list, more: (pageInfo.page < pageInfo.totalPage) };
    }

    getcontextdata(){
        var id=TSLobsterAPI.Program.RequestQuery("id", "0");
        var item=this.dao.getcontextdata(id);
        return {data:item};
    }

    updatetotalhit(){
        var cid=TSLobsterAPI.Program.RequestQuery("cid", "0");
        this.dao.updatetotalhit(cid);
        return { result: true };
    }
}